package com.hengpeng.itfinoss.service.investInfo.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import com.hengpeng.common.persist.query.DynamicQuery;
import com.hengpeng.itfinbase.en.InvestStatus;
import com.hengpeng.itfinbase.persist.InvestInfo;
import com.hengpeng.itfinoss.service.ServiceFactory;
import com.hengpeng.itfinoss.service.investInfo.InvestInfoService;

@Lazy
@Service
public class InvestInfoServiceImpl implements InvestInfoService {
    @Autowired
    private ServiceFactory serviceFactory;

    @Override
    public List<InvestInfo> getInvestInfos(Long borrowinfoId, InvestStatus[] status) {
        DynamicQuery query = new DynamicQuery(InvestInfo.class);
        if (borrowinfoId != null) {
            query.eq("borrowinfoId", borrowinfoId);
        }
        if (status != null && status.length > 0) {
            query.inArray("status", status);
        }
        return serviceFactory.getPersistService().find(InvestInfo.class, query);
    }

}
